package de.lianowar.whereismymoney.adapter;

import java.util.ArrayList;

import de.lianowar.whereismymoney.R;
import de.lianowar.whereismymoney.sql.data.Account;
import de.lianowar.whereismymoney.sql.data.MoneyAmount;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Spinner;
import android.widget.TextView;

public class AccountListAdapter extends BaseAdapter {

	private Activity context;
	private ArrayList<Account> money;
	
    public AccountListAdapter(Activity context, ArrayList<Account> pMoneyAmount){
        this.context=context;
        money=pMoneyAmount;
    }
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return money.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return money.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return money.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		   View spinView;
		    if( convertView == null ){
		    	LayoutInflater inflater = context.getLayoutInflater();
		        spinView = inflater.inflate(R.layout.accountspinner_layout, null);
		    } else {
		         spinView = convertView;
		    }
		    TextView t1 = (TextView) spinView.findViewById(R.id.tvAccountName);

		    t1.setText(String.valueOf(money.get(position).getName()));
		;
		    return spinView;
		    }
	

}
